const mongoose = require('mongoose');
const url = 'mongodb://127.0.0.1:27017';
const dbName = 'myblog01';

mongoose.set('useCreateIndex', true);
mongoose.connect(`${url}/${dbName}`, {
    useNewUrlParser: true,
    useUnifiedTopology: true
})

const db = mongoose.connection;

db.on('err',err=>{
    console.log('mongoose connection '+ err)
})

// db.once('open', () => {
//     console.log('mongose connection success')

// })
module.exports = mongoose;
